import com.alibaba.fastjson.JSONObject;

import java.sql.SQLException;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws SQLException, ClassNotFoundException {


        String e="{\n" +
                "  \"dataSourceList\": [\n" +
                "    {\n" +
                "      \"connectionName\": \"connectionName1\",\n" +
                "      \"driverClassName\": \"com.mysql.cj.jdbc.Driver\",\n" +
                "      \"password\": \"root\",\n" +
                "      \"url\": \"jdbc:mysql://47.95.222.102:3306/test\",\n" +
                "      \"userName\": \"root\"\n" +
                "    }\n" +
                "  ],\n" +
                "  \"node\": {\n" +
                "    \"dataList\": [\n" +
                "      {\n" +
                "        \"connectionName\": \"connectionName1\",\n" +
                "        \"dataName\": \"data1\",\n" +
                "        \"source\": \"sql\",\n" +
                "        \"sql\": \"select now() as time\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"connectionName\": \"connectionName1\",\n" +
                "        \"dataName\": \"data2\",\n" +
                "        \"source\": \"sql\",\n" +
                "        \"sql\": \"select * from test2 limit 0,10\"\n" +
                "      }\n" +
                "    ],\n" +
                "    \"nodeList\": [\n" +
                "      {\n" +
                "        \"node\": {\n" +
                "          \"dataList\": [\n" +
                "            {\n" +
                "              \"connectionName\": \"connectionName1\",\n" +
                "              \"dataName\": \"data1\",\n" +
                "              \"filterList\": [\n" +
                "                {\n" +
                "                  \"colName\": \"id\",\n" +
                "                  \"filterSource\": \"parent->child_name3->data1->id\",\n" +
                "                  \"filterType\": \"in\"\n" +
                "                }\n" +
                "              ],\n" +
                "              \"source\": \"sql\",\n" +
                "              \"sql\": \"select  * from test2 limit 0,100\"\n" +
                "            }\n" +
                "          ],\n" +
                "          \"nodeList\": [],\n" +
                "          \"nodeName\": \"name2\"\n" +
                "        }\n" +
                "      },\n" +
                "      {\n" +
                "        \"node\": {\n" +
                "          \"dataList\": [\n" +
                "            {\n" +
                "              \"connectionName\": \"connectionName1\",\n" +
                "              \"dataName\": \"data1\",\n" +
                "              \"source\": \"sql\",\n" +
                "              \"sql\": \"select  id from department\"\n" +
                "            }\n" +
                "          ],\n" +
                "          \"nodeList\": [],\n" +
                "          \"nodeName\": \"name3\"\n" +
                "        }\n" +
                "      }\n" +
                "    ],\n" +
                "    \"nodeName\": \"name1\"\n" +
                "  }\n" +
                "}";
        
        String f="{\n" +
                "  \"dataSourceList\": [\n" +
                "    {\n" +
                "      \"connectionName\": \"connectionName1\",\n" +
                "      \"driverClassName\": \"com.mysql.cj.jdbc.Driver\",\n" +
                "      \"password\": \"root\",\n" +
                "      \"url\": \"jdbc:mysql://47.95.222.102:3306/test\",\n" +
                "      \"userName\": \"root\"\n" +
                "    }\n" +
                "  ],\n" +
                "  \"node\": {\n" +
                "    \"dataList\": [\n" +
                "      {\n" +
                "        \"connectionName\": \"connectionName1\",\n" +
                "        \"dataName\": \"data1\",\n" +
                "        \"source\": \"sql\",\n" +
                "        \"sql\": \"select now() as time\",\n" +
                "        \"nodeType\":0\n" +
                "      },\n" +
                "      {\n" +
                "        \"connectionName\": \"connectionName1\",\n" +
                "        \"dataName\": \"data2\",\n" +
                "        \"source\": \"sql\",\n" +
                "        \"sql\": \"select * from test2 limit 0,10\",\n" +
                "        \"nodeType\":1\n" +
                "      },\n" +
                "\t   {\n" +
                "        \"connectionName\": \"connectionName1\",\n" +
                "        \"dataName\": \"data3\",\n" +
                "        \"source\": \"sql\",\n" +
                "        \"sql\": \"select 639 as id\",\n" +
                "        \"nodeType\":0\n" +
                "      }\n" +
                "    ],\n" +
                "    \"nodeList\": [\n" +
                "      {\n" +
                "        \"node\": {\n" +
                "          \"dataList\": [\n" +
                "            {\n" +
                "              \"connectionName\": \"connectionName1\",\n" +
                "              \"dataName\": \"data1\",\n" +
                "              \"filterList\": [\n" +
                "                {\n" +
                "                  \"colName\": \"id\",\n" +
                "                 \"filterSource\": \"parent->data3->id\",\n" +
                "                  \"filterType\": \"<\"\n" +
                "                }\n" +
                "              ],\n" +
                "              \"source\": \"sql\",\n" +
                "              \"sql\": \"select  * from test2 limit 0,100\",\n" +
                "               \"nodeType\":1\n" +
                "            }\n" +
                "          ],\n" +
                "          \"nodeList\": [],\n" +
                "          \"nodeName\": \"name2\"\n" +
                "        }\n" +
                "      },\n" +
                "      {\n" +
                "        \"node\": {\n" +
                "          \"dataList\": [\n" +
                "            {\n" +
                "              \"connectionName\": \"connectionName1\",\n" +
                "              \"dataName\": \"data1\",\n" +
                "              \"source\": \"sql\",\n" +
                "              \"sql\": \"select  id from department\",\n" +
                "              \"nodeType\":1\n" +
                "            }\n" +
                "          ],\n" +
                "          \"nodeList\": [],\n" +
                "          \"nodeName\": \"name3\"\n" +
                "        }\n" +
                "      }\n" +
                "    ],\n" +
                "    \"nodeName\": \"name1\"\n" +
                "  }\n" +
                "}";
        System.out.println(f);
        Root root=new Root();
        root.setNode(new Node());
        Conversion conversion=new Conversion();
//        conversion.decode(e,root);
//        String data=conversion.encode(root);
//        System.out.println("Hello World!");
//        System.out.println(data);
//
      
        String out=conversion.getJsonString(f);
        System.out.println(out);

    }
}
